package cn.kgc.model.controller;

import cn.kgc.common.utils.ResultUtils;
import cn.kgc.common.utils.result.Result;
import cn.kgc.model.entity.Classify;
import cn.kgc.model.entity.dto.ClassifyDto;
import cn.kgc.model.service.ClassifyService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品分类 前端控制器
 * </p>
 *
 * @author qf
 * @since 2021-08-04
 */
@RestController
@RequestMapping("/api/home")
public class ClassifyController {

    private final ClassifyService classifyService;

    public ClassifyController(ClassifyService classifyService) {
        this.classifyService = classifyService;
    }

    @GetMapping("all")
    public List<Classify> findAll() {
        List<Classify> list = classifyService.list();
        return list;
    }

    @GetMapping("classifyTree")
    public Result<List<ClassifyDto>> getClassifyTree() {
        List<ClassifyDto> list = classifyService.getClassifyTree();
        return ResultUtils.returnDataSuccess(list);
    }
}

